public class LinearSearchTest {
    public static void main(String[] args) {
//        Integer[] data1 = new Integer[]{1, 2, 34};
//        int result1 = LinearSearch.INSTANCE.search(data1, 2);
//        System.out.println("result1 = " + result1);
//        String[] data2 = {"aaa", "bbb", "ccc", "ddd"};
//        int result2 = LinearSearch.INSTANCE.search(data2, "ddd");
//        System.out.println("result2 = " + result2);
////基本数据类型报错，泛型不能使用基本数据类型
////        int[] data3 = new int[]{1, 2};
////        System.out.println(LinearSearch.INSTANCE.search(data3, 1));
//
//        Student[] data4 = new Student[]{
//                new Student("stu1","学生1",22,"清华大学1"),
//                new Student("stu2","学生2",23,"清华大学2"),
//                new Student("stu3","学生3",24,"清华大学3"),
//                new Student("stu4","学生4",25,"清华大学4"),
//                new Student("stu5","学生5",26,"清华大学5"),
//        };
//        int result4 = LinearSearch.INSTANCE.search(data4, new Student("stu1", "学生1", 22, "清华大学2"));
//        System.out.println("result4 = " + result4);
//        int result5 = LinearSearch.INSTANCE.search(data4, new Student("stu1", "学生1", 22, "清华大学1"));
//        System.out.println("result5 = " + result5);
        //1000000   0.1431112
        //10000000  1.269741
        int[] dataSize = {1000000, 10000000};
        for (int n : dataSize) {
            Integer[] data = ArrayGenerator.INSTANCE.generatorOrderedArray(n);
            long startTime = System.nanoTime();
            for (int i = 0; i < 100; i++)
                LinearSearch.INSTANCE.search(data, n);
            Long end = System.nanoTime();
            double time = (end - startTime) / 1000000000.0;
            System.out.println("time = " + time);
        }


    }
}
